﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class webadmin_pages_popup_src_vlt : System.Web.UI.Page
{
    private Common _common;
    protected void btn_search_Click(object sender, EventArgs e)
    {
        string sql = "select A.ma_ho_so, A.tieu_de_ho_so, A.vi_tri_tuyen_dung, B.ten_doanh_nghiep, B.ten_tat from ViecLamTrong_ho_so_tuyen_dung as A inner join DoanhNghiep_doanh_nghiep as B on A.ma_doanh_nghiep = B.ma_doanh_nghiep ";
        sql = sql + " left outer join (select N.ma_ho_so, N.ma_chuyen_mon, M.ten_chuyen_mon from ViecLamTrong_yeu_cau_chuyen_mon as N inner join DanhMuc_chuyen_mon as M " + " on N.ma_chuyen_mon = M.ma_chuyen_mon) as C on A.ma_ho_so = C.ma_ho_so where A.ma_ho_so != '' ";
        if (!this.txt_src_tieude.Text.Trim().Equals(""))
        {
            sql = sql + " and A.tieu_de_ho_so like N'%" + this._common.TextFormat(this.txt_src_tieude.Text) + "%' ";
        }
        if (!this.txt_src_tendoanhnghiep.Text.Trim().Equals(""))
        {
            sql = sql + " and B.ten_doanh_nghiep like N'%" + this._common.TextFormat(this.txt_src_tendoanhnghiep.Text) + "%' ";
        }
        if (!this.txt_src_tentat.Text.Trim().Equals(""))
        {
            sql = sql + " and B.ten_tat like N'%" + this._common.TextFormat(this.txt_src_tentat.Text) + "%' ";
        }
        if (this.drop_src_chuyenmon.SelectedIndex != 0)
        {
            if (this.drop_src_chuyenmon1.Items.Count > 0)
            {
                sql = sql + " and C.ma_chuyen_mon = '" + this.drop_src_chuyenmon1.SelectedValue + "' ";
            }
            else
            {
                sql = sql + " and C.ma_chuyen_mon = '" + this.drop_src_chuyenmon.SelectedValue + "' ";
            }
        }
        this.rpt_csdt.DataSource = this._common.ExeceuteDataset(sql);
        this.rpt_csdt.DataBind();
    }

    protected void drop_src_chuyenmon_SelectedIndexChanged(object sender, EventArgs e)
    {
        this.drop_src_chuyenmon1.DataSource = this._common.ExeceuteDataset("select * from DanhMuc_chuyen_mon where ma_chuyen_mon_cha = '" + this.drop_src_chuyenmon.SelectedValue + "'");
        this.drop_src_chuyenmon1.DataTextField = "ten_chuyen_mon";
        this.drop_src_chuyenmon1.DataValueField = "ma_chuyen_mon";
        this.drop_src_chuyenmon1.DataBind();
    }

    private void LoadChuyenmon()
    {
        this.drop_src_chuyenmon.DataSource = this._common.ExeceuteDataset("select * from DanhMuc_chuyen_mon where muc = 0");
        this.drop_src_chuyenmon.DataTextField = "ten_chuyen_mon";
        this.drop_src_chuyenmon.DataValueField = "ma_chuyen_mon";
        this.drop_src_chuyenmon.DataBind();
        this.drop_src_chuyenmon.Items.Insert(0, new ListItem("Chọn chuy\x00ean m\x00f4n", "0"));
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            this._common = new Common();
            if (!base.IsPostBack)
            {
                this.LoadChuyenmon();
            }
        }
        catch (Exception)
        {
        }
    }
}
